package NG::Sys::Cache::Base;
use strict;
use warnings;
use utf8;

sub new {
	my ($class,$args) = @_;
	my $self = bless $args, $class;
	$self->bild_prefix;
	$self->create_cache;
	return $self;
}
sub clone {
	my ($self,$namespace) = @_;
	my %self = %$self;
	$self{namespace} = $namespace;
	my $class = ref $self;
	$self = bless \%self, $class;
	$self->bild_prefix;
	return $self;
}
sub bild_prefix {
	my ($self) = @_;
	$self->{prefix} = ($self->{filename}||"").":".($self->{namespace}||"").":";
}
sub prefix {
	my ($self) = @_;
	return $self->{prefix};
}
sub create_cache {
	my ($self) = @_;
	$self->{cache} = undef;
}
sub get {
	my ($self,$key) = @_;
	return $self->{cache}->get($self->{prefix}.$key);
}
sub set {
	my ($self,$key,$value,@rest) = @_;
	return $self->{cache}->set($self->{prefix}.$key,$value,@rest);
}
sub remove {
	my ($self,$key) = @_;
	return $self->{cache}->remove($self->{prefix}.$key);
}
sub clear {
	my ($self) = @_;
	$self->{cache}->clear;
}
1;
